package com.ichina.chat.util;

import javax.servlet.http.HttpServletResponse;

public class MessageListUtil {
	private static HttpServletResponse response;
	public static void main(String[] args) {
		System.err.println(MessageListUtil.getList(new Object[]{"序号","名称"}, new Object[]{new Object[]{"1","a"},new Object[]{"2","我所见"}},"" ,"Type", "c2", 1, 5, 1, 1));
	}
	public static String getList(Object[] com,Object[] s,String sss,String vo,String c,int cp,int pagesize,int pagecount,int count){
		StringBuffer str = new StringBuffer();
		
		str.append("<table width='100%' border='0' cellspacing='0' cellpadding='0'>");
		str.append("<tr><td height='30' background='tab/images/tab_05.gif'><table width='100%' border='0' cellspacing='0' cellpadding='0'>");
		str.append("<tr><td width='12' height='30'><img src='tab/images/tab_03.gif' width='12' height='30' /></td>");
		str.append("<td><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td width='46%' valign='middle'><table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td width='5%'><div align='center'><img src='tab/images/tb.gif' width='16' height='16' /></div></td><td width='95%' class='STYLE1'><span class='STYLE3'>你当前的位置</span>：[角色管理]-[角色列表]</td></tr></table></td>");
		str.append("<td width='54%'><table border='0' align='right' cellpadding='0' cellspacing='0'> <tr><td width='60'><table width='87%' border='0' cellpadding='0' cellspacing='0'>");
		str.append("<tr><td class='STYLE1'><div align='center'><input type='checkbox' name='checkbox62' value='checkbox' /> </div></td><td class='STYLE1'><div align='center'>全选</div></td></tr></table></td>");
		str.append("<td width='60'><table width='90%' border='0' cellpadding='0' cellspacing='0'><tr><td class='STYLE1'><div align='center'><img src='tab/images/22.gif' width='14' height='14' /></div></td><td class='STYLE1'><div align='center'>新增</div></td></tr></table></td>");
		str.append("<td width='60'><table width='90%' border='0' cellpadding='0' cellspacing='0'><tr><td class='STYLE1'><div align='center'><img src='tab/images/33.gif' width='14' height='14' /></div></td><td class='STYLE1'><div align='center'>修改</div></td></tr></table></td>");
		str.append("<td width='52'><table width='88%' border='0' cellpadding='0' cellspacing='0'><tr><td class='STYLE1'><div align='center'><img src='tab/images/11.gif' width='14' height='14' /></div></td><td class='STYLE1'><div align='center'>删除</div></td></tr></table></td></table></td></table>");
		str.append("<td width='16'><img src='tab/images/tab_07.gif' width='16' height='30' /></td></table></td>");
		//操作加载完成
		//中间面的tr开始
		str.append("<tr><td><table width='100%' border='0' cellspacing='0' cellpadding='0'>");
		str.append("<tr>");
		//-------onmouseover='changeto()' onmouseout='changeback()'
		str.append("<table width='100%' border='0' cellpadding='0' cellspacing='1' bgcolor='b5d6e6' >");
		str.append("<tr><td width='3%' height='22' background='images/bg.gif' bgcolor='#FFFFFF'><div align='center'><input type='checkbox' name='checkbox' value='checkbox' /></div></td>");
		StringBuffer mtd = new StringBuffer();
		for(int i = 0 ; i< com.length ; i++){
			str.append("<td height='22' background='images/bg.gif' bgcolor='#FFFFFF'><div align='center'><span class='STYLE1'>");
			str.append(com[i]);
			str.append("</span></div></td>");
		//	mtd.append( "<td  height='20'><div align='center'><span class='STYLE1'>&"+i+"&</span></div></td>");
		}
		System.err.println(mtd.toString());
		str.append("<td width='15%' height='22' background='images/bg.gif'bgcolor='#FFFFFF' class='STYLE1'><div align='center'>基本操作</div></td></tr>");
		for(int i = 0 ; i< s.length ; i++){
			Object[] a = (Object[]) s[i];
			str.append("<tr bgcolor='#ffffff' onmouseover='changeto(this)' onmouseout='changeback(this)'><td height='20'>" +
					"<div align='center'><input type='checkbox' name='checkbox14' value='checkbox' /></div></td>");
			for(int j = 0 ; j < a.length ; j++ ){
				str.append(StringReplacer.replaceString("<td  height='20'><div align='center'><span class='STYLE1'>&d&</span></div></td>","&d&",a[j].toString()));
			}
			str.append("<td height='20'><div align='center'><span class='STYLE4'><span onclick=edit('bg_edit.action','"+a[0].toString()+"','"+vo+"','"+sss+"')><img src='tab/images/edt.gif'width='16' height='16' />编辑</span>" +
					"&nbsp; &nbsp;<span onclick=del('"+c+"','bg_del.action','"+a[0].toString()+"',"+cp+",'"+vo+"','"+sss+"')><img src='tab/images/del.gif' width='16' height='16' />删除</span></span></div></td>");
			str.append("</tr>");
		}
		
		//中间的tr结束
		str.append("</table></td></tr>");
		//底部tr开始
		str.append("<tr><td height='35' width='100%' background='tab/images/tab_19.gif'>");
		str.append("<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td width='12' height='35'><img src='tab/images/tab_18.gif' width='12' height='35' />");
		str.append("</td><td><table width='100%' border='0' cellspacing='0' cellpadding='0'>");
		str.append("<tr><td class='STYLE4'>&nbsp;&nbsp;共有 "+count+" 条记录，当前第 "+cp+"/"+pagecount+" 页");
		str.append("</td><td><table border='0' align='right' cellpadding='0' cellspacing='0'><tr>");
		//分页
		str.append("<td width='40'><img "+ (cp == 1 ? " src='tab/images/first1.gif' ":"onclick=updateCp('"+c+"','bg_load"+vo+".action',1) src='tab/images/first.gif' ") +" width='37' height='15' /></td>");
		str.append("<td width='45'><img "+ (cp == 1 ? "src='tab/images/back1.gif'":"onclick=updateCp('"+c+"','bg_load"+vo+".action',"+(cp == 1 ? cp: cp-1)+") src='tab/images/back.gif' ") + " width='43' height='15' /></td>");
		str.append("<td width='45'><img "+ (cp == pagecount ? "src='tab/images/next1.gif' ":"onclick=updateCp('"+c+"','bg_load"+vo+".action',"+(cp == pagecount ? pagecount: cp+1)+") src='tab/images/next.gif' ") + " width='43' height='15' /></td>");
		str.append("<td width='40' ><img  "+ (cp == pagecount ? " src='tab/images/last1.gif' ":"onclick=updateCp('"+c+"','bg_load"+vo+".action',"+pagecount+") src='tab/images/last.gif' ") + " width='37' height='15' /></td><td width='100'><div align='center'>");
		//------------
		str.append("<span class='STYLE1'>转到第 <input name='textfield' type='text' size='4' style='height: 12px; width: 20px; border: 1px solid #999999;' />页 </span>");
		str.append("</div></td><td width='40'><img src='tab/images/go.gif' width='37' height='15' />");
		str.append("</td></tr></table></td></tr></table></td><td width='16'><img src='tab/images/tab_20.gif' width='16' height='35' /></td></tr></table>");
		//底部的tr结束
		str.append("</td></tr></table>");
		return str.toString();
	}
}
